Skip to content

fix(goal): retry ESC pause persistence before giving up the goal - #284

Merged
LeXwDeX merged 1 commit into
devfrom
fix/goal-esc-retry
Aug 15, 2026
Merged

fix(goal): retry ESC pause persistence before giving up the goal#284
LeXwDeX merged 1 commit into
devfrom
fix/goal-esc-retry

Conversation

@LeXwDeX

@LeXwDeX LeXwDeX commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Problem

审计发现 F5:pauseForUserCancel(ESC 暂停 goal)若遇到瞬时 DB 写失败,会静默丢失暂停——turnDriven 标记已清、暂停未落库,下一个 idle 事件让 goal 违背用户明确的 ESC 意图而复活。shouldPreempt 无法捕获 ESC(ESC 不产生 user 消息,lastUser 必早于 assistant)。

Fix

pauseForUserCancel 改为显式重试循环:最多 3 次尝试(初次 + 2 次重试,50ms 退避)。用 Effect.exit 捕获完整 Cause(含 defect,避开 Effect.retry 对 defect 的歧义);成功才 unregister lease;重试用尽改为 logError 高亮记录——goal 即使复活也绝不隐形。

Evidence

  • typecheck 干净;test/goal 103 pass(happy-path 由 turn-scope.test.ts 覆盖)
  • 重试分支无干净故障注入缝隙:测试 DB 为 :memory:pauseAndPublish 是 drizzle orDie 之上的 layer 闭包。按诊断纪律记录缝隙缺失,未硬造测试。

上下文

继 GOAL-FP-01-17(#283)后的收尾。goal-loop 静默失败面收敛计划的一环。

A transient DB failure during pauseForUserCancel would silently lose the
pause: the turnDriven mark cleared, the pause never persisted, and the next
idle event resurrected the goal against the user's explicit ESC
(shouldPreempt cannot catch ESC — it adds no user message). Retry the pause
up to twice with 50ms backoff (Effect.exit captures defects, unlike typed
retry); on exhausted retries log loudly instead of warning, so a resurrecting
goal is never invisible.

No clean fault-injection seam for the retry branch (test DB is :memory:,
pauseAndPublish is a layer closure over drizzle orDie) — happy path covered
by test/goal/turn-scope.test.ts; seam absence recorded per diagnosis policy.
@LeXwDeX
LeXwDeX merged commit b02c727 into dev Aug 15, 2026
5 checks passed
@LeXwDeX
LeXwDeX deleted the fix/goal-esc-retry branch August 15, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant